import 'package:adjust_sdk/adjust_config.dart';

/// 业务配置模型类
class BusinessConfigModel {
  // 调试设置
  final bool debugEnabled; //是否打印日志

  // Google Firebase配置
  final String apiKey; //GoogleService-Info.plist里的：API_KEY
  final String appId; //GoogleService-Info.plist里的：GOOGLE_APP_ID
  final String messagingSenderId; //GoogleService-Info.plist里的：GCM_SENDER_ID
  final String projectId; //GoogleService-Info.plist里的：PROJECT_ID
  final String storageBucket; //GoogleService-Info.plist里的：STORAGE_BUCKET
  final String iosBundleId; //iOS的BundleId
  final String googleTestDeviceId; // Google 官方测试设备 ID

  // AdMob广告平台
  final String flyOpenId; //开屏广告ID
  final String bannerAdId; //插屏广告ID
  final String rewardedAdId;//激励视频广告ID
  final bool releaseAdvertisement; //是否使用正式广告

  // 数数平台
  final String tdAppId; //数数科技平台创建应用后获得的唯一应用ID
  final String tdServerUrl; //数据上报的服务器地址

  // Adjust归因平台
  final bool adjustIsDebug; //是否使用沙河模式，否则使用正式模式（卸载监测必须使用正式环境）
  final String adjustId; //Adjust 应用令牌（App Token），这是在 Adjust 平台上创建应用后获得的唯一标识符。
  /*
  verbose (最详细) - 输出所有可能的信息
  debug - 调试信息和更高级别日志
  info - 一般信息性日志
  warn - 仅警告和错误
  error - 仅错误信息
  suppress (最安静) - 不输出任何日志
  */
  final AdjustLogLevel adjustLogLevel; //日志等级
  final String adNetwork;
  final String campaignName; //广告活动名称，表示用户通过哪个广告活动(Campaign)安装或打开了您的应用
  final String adgroup; //广告组名称，表示用户通过哪个广告组(Ad Group)安装或打开了您的应用
  final String creative; //广告创意名称，表示用户通过哪个广告创意(Creative)安装或打开了您的应用
  final String adid; //Adjust 设备 ID

  Map<String, dynamic>? reportExtraParameters; //上报的额外参数

  BusinessConfigModel({
    // 调试设置
    this.debugEnabled = false,

    // Google Firebase配置
    required this.apiKey,
    required this.appId,
    required this.messagingSenderId,
    required this.projectId,
    required this.storageBucket,
    required this.iosBundleId,
    this.googleTestDeviceId = '2077ef9a63d2b398840261c8221a0c9b',

    // AdMob广告平台
    required this.flyOpenId,
    required this.bannerAdId,
    required this.rewardedAdId,
    this.releaseAdvertisement = true,

    // 数数平台
    required this.tdAppId,
    required this.tdServerUrl,

    // Adjust归因平台
    this.adjustIsDebug = false,
    required this.adjustId,
    this.adjustLogLevel = AdjustLogLevel.verbose,
    this.adNetwork = "adNetwork",
    this.campaignName = "campaignName",
    this.adgroup = "adgroup",
    this.creative = "creative",
    this.adid = "adid",
    this.reportExtraParameters,
  });

  static AdjustLogLevel parseAdjustLogLevel(String? level) {
    switch (level?.toLowerCase()) {
      case 'verbose':
        return AdjustLogLevel.verbose;
      case 'debug':
        return AdjustLogLevel.debug;
      case 'info':
        return AdjustLogLevel.info;
      case 'warn':
        return AdjustLogLevel.warn;
      case 'error':
        return AdjustLogLevel.error;
      case 'suppress':
        return AdjustLogLevel.suppress;
      default:
        return AdjustLogLevel.verbose;
    }
  }
}
